package com.dangf.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dangf.entity.User;
import com.dangf.service.UserService;
import com.dangf.utils.IsNullUtils;

/**
 * 用户控制器
 * 
 * @author hais1992
 */
@Controller
@RequestMapping("/user")
public class UserController extends BaseController{
	@Resource
	private UserService userService;
	
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> index(User u) {
		if(u.getId() == 0){
			return setResult(HTTP_CODE_FAILED, "修改失败，参数不全！", "");
		}else if(IsNullUtils.stringIsNull(u.getUsername())){
			return setResult(HTTP_CODE_FAILED, "修改失败，用户名不能为空！", "");
		}else{
			User user = new User();
			if(u.getId()!=0)user.setId(u.getId());
			if(IsNullUtils.stringIsNull(u.getName()))user.setName(u.getName());
			if(IsNullUtils.stringIsNull(u.getEmail()))user.setEmail(u.getEmail());
		}
		
		
		
		return result;
	}

}
